import 'package:flutter/material.dart';
import '../../l10n/app_localizations.dart';
import '../../models/serach_info_model.dart';

class ConfirmTopView extends StatelessWidget {
  final ReListModel model;
  final int pricenum;
  final String producttype;
  
  const ConfirmTopView({Key? key, required this.model,required this.pricenum,required this.producttype}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 135,
      margin: const EdgeInsets.only(top: 15, left: 15, right: 15),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(15),
      ),
      child: Column(
        children: [
          // 顶部按钮区域
          Container(
            height: 35,
            width: double.infinity,
            decoration: BoxDecoration(
              color: Color(0xFF6A6CE5),
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(15),
                topRight: Radius.circular(15),
              ),
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                _buildFeatureButton(context, 0, AppLocalizations.of(context)!.serviceGuarantee),
                _buildFeatureButton(context, 1, AppLocalizations.of(context)!.fastProcessing),
                if (isChineseLocale())
                _buildFeatureButton(context, 2, AppLocalizations.of(context)!.safeAndReliable),
                if (isChineseLocale())
                _buildFeatureButton(context, 3, AppLocalizations.of(context)!.priorityCompensation),
              ],
            ),
          ),
          // 内容区域
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 15),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                // 图片
                Container(
                  width: 70,
                  height: 70,
                  margin: const EdgeInsets.only(top: 15),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(13),
                    image: DecorationImage(
                      image: NetworkImage(model.pic),
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
                SizedBox(width: 12),
                // 文字区域
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(height: 17),
                      SizedBox(
                        height: 40,
                        child: Align(
                          alignment: Alignment.centerLeft,
                          child: Text(
                            model.name,
                            style: TextStyle(
                              color: Color(0xFF000000),
                              fontSize: 15,
                              height: 0.9,
                            ),
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                          ),
                        ),
                      ),
                      // SizedBox(height: 5),
                      Row(
                        children: [
                          Flexible(
                            child: Text(
                              '${AppLocalizations.of(context)!.type}：$producttype',
                              maxLines: 2,
                              overflow: TextOverflow.ellipsis,
                              style: TextStyle(
                                color: Color(0xFF7B7B7B),
                                fontSize: 12,
                                fontWeight: FontWeight.bold,
                              ),
                            ),
                          ),
                          SizedBox(width: 25), // 固定 25px 间距
Container( padding: EdgeInsets.symmetric(horizontal: 8, vertical: 2), decoration: BoxDecoration( color: Color(0xFFF4F4F4), borderRadius: BorderRadius.circular(11), ), child: Text( isChineseLocale() ? '${AppLocalizations.of(context)!.totalof}$pricenum${AppLocalizations.of(context)!.items}' : 'X$pricenum', style: TextStyle( color: Color(0xFF666666), fontSize: 11, fontWeight: FontWeight.bold, letterSpacing: 1.0 ), ), ),
                        ],
                      )


                    ],
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildFeatureButton(BuildContext context, int index, String title) {
    return GestureDetector(
      onTap: () {},
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Image.asset(
            'assets/images/order_icon${index + 1}.png',
            width: 16,
            height: 16,
          ),
          SizedBox(width: 4),
          Text(
            title,
            style: TextStyle(
              color: Colors.white,
              fontSize: MediaQuery.of(context).size.width > 375 ? 15 : 13,
            ),
          ),
        ],
      ),
    );
  }
}